package Messages;

import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import ocsf.server.ConnectionToClient;
import server.SQLConnection;
/**
 * This class implements vase inventory from the DB 
 * @author Gabi Revah
 * @author Aviad Almog
 */ 
public class MessageVaseInv {
	private ConnectionToClient client ;
	private String[] str; 
/**
 * Constructor of this class 
 * @param str
 * @param client
 */
	public MessageVaseInv(String[] str, ConnectionToClient client) {
		this.client= client ;
		this.str= str; 
	
	}
	/**
	 * This method get vase inventory from the DB 
	 * @throws SQLException
	 * @throws IOException
	 */
	
public void VaseInv() throws SQLException, IOException{
		
		
		SQLConnection sc = new SQLConnection();
		java.sql.PreparedStatement ps = sc.getConnection().prepareStatement("SELECT * FROM db.vases");
		ResultSet VaseInvRes= ps.executeQuery();
		ArrayList<Object> vi=new ArrayList<Object>();
		vi.add("VaseInv");
		while (VaseInvRes.next())
		{
			vi.add(VaseInvRes.getString(1));
			vi.add(VaseInvRes.getString(2));
			vi.add(VaseInvRes.getInt(3));
			vi.add(VaseInvRes.getInt(4));
			vi.add(VaseInvRes.getInt(5));
			vi.add(VaseInvRes.getInt(6));
		}
		client.sendToClient(vi);
	}
}
